<template>
  <div class="collection">
    <div class="label-name">我的信息</div>
    <div class="evaluate-all">
      <ul>
        <li v-for="(item, index) in messageList" :key="index">
          <div class="message-item" @click="goGame(item.giId)">
            <div class="message-img">
              <img :src="item.uimg" alt="" />
            </div>
            <div class="message-text">
              <div>
                <span class="username">{{ item.uname }}</span> 回复了我的评论
              </div>
              <div>
                {{ item.grContent }}
              </div>
              <div class="text-bottom">
                <div>{{ item.grStatetime }}</div>
                <!-- <div class="delemessage">
                  <img src="../../../assets/img/dele .svg" alt="" />
                  <div>删除此信息</div>
                </div> -->
              </div>
            </div>
            <div class="message-my">
              <img :src="item.giLogo" alt="" />
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { myReplyComments } from "../../../network/usermes";
export default {
  name: "message",
  data() {
    return {
      messageList: [],
      pages: 1,
      page: "",
    };
  },

  created() {
    this.getMessage();
  },
  mounted() {
    window.addEventListener("scroll", this.scrollNav);
  },

  methods: {
    getMessage() {
      myReplyComments(this.pages, this.$Cookie.get("userid")).then((res) => {
        console.log(res);
        this.page = res.data.data.pages;
        if (this.pages > this.page) {
          console.log(this.pages);
        } else {
          this.pages += 1;
          this.messageList.push(...res.data.data.list);
        }
      });
    },

    scrollNav() {
      let bottom =
        document.documentElement.scrollHeight -
        document.documentElement.scrollTop -
        document.documentElement.clientHeight;
      if (bottom < 150 && this.pages <= this.page) {
        this.myReplyComments();
      }
    },

    goGame(id) {
      this.$router.push({ name: "详情", params: { id: id } });
    },
  },
};
</script>

<style>
.message-item {
  display: flex;
  cursor: pointer;
  margin-top: 0.12rem;
}
.message-img {
  flex: 0.7;
}

.message-img img {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
}

.message-text {
  flex: 8;
}

.username:hover {
  color: rgb(36, 184, 242);
}

.message-text div:nth-child(1) {
  font-size: 0.1rem;
  margin-bottom: 0.1rem;
}

.message-text div:nth-child(1) span {
  font-size: 0.11rem;
  font-weight: bold;
}

.message-text div:nth-child(2) {
  font-size: 0.095rem;
}

.text-bottom {
  display: flex;
  align-items: center;
  margin-top: 0.12rem;
}

.text-bottom div:nth-child(1) {
  transform: translateY(50%);
  font-size: 0.08rem;
  margin-right: 0.2rem;
}

.text-bottom div img {
  width: 0.1rem;
  height: 0.1rem;
}

.message-item:hover .delemessage {
  display: block;
  display: flex;
}

.delemessage {
  display: flex;
  align-items: center;
  display: none;
}

.delemessage:hover {
  color: rgb(36, 184, 242);
}

.delemessage img {
  margin-right: 0.05rem;
}

.message-my {
  flex: 1;
  height: 0.6rem;
  font-size: 0.09rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}

.message-my img {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 0.05rem;
}
</style>